unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls,frxClass,frxPreview, StdCtrls, ComCtrls, frxExportPDF,
  frxExportRTF,frxExportImage,frxExportMatrix,frxExportXLS,frxExportXML,
  frxDesgn,frxPreviewPages;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    Button4: TButton;
    Button5: TButton;
    Button6: TButton;
    Button7: TButton;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
  private
    { Private declarations }
    FPreview : TfrxPreview;
    FReport3: TfrxReport;
    FReportTmp: TfrxReport;
    FPDFExport :TfrxPDFExport;
    FBMPExport :TfrxBMPExport;
    FTIFFExport :TfrxTIFFExport;
    FJPEGExport :TfrxJPEGExport;
    FRTFExport :TfrxRTFExport;
    FXLSExport :TfrxXLSExport;
    FXMLExport :TfrxXMLExport;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  frxCharset := GB2312_CHARSET;
  FPreview := TfrxPreview.Create(Self);
  FPreview.Parent := TabSheet1;
  FPreview.Align := alClient;
  FPreview.Zoom := 0.8;

  FReport3 := TfrxReport.Create(Self);

  FReportTmp := TfrxReport.Create(Self);

  FPDFExport := TfrxPDFExport.Create(Self);
  FBMPExport :=TfrxBMPExport.Create(Self);
  FTIFFExport :=TfrxTIFFExport.Create(Self);
  FJPEGExport :=TfrxJPEGExport.Create(Self);
  FRTFExport :=TfrxRTFExport.Create(Self);
  FXLSExport :=TfrxXLSExport.Create(Self);
  FXMLExport :=TfrxXMLExport.Create(Self);

end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FReport3.Preview := nil;
  FReport3.Free;
  FPreview.Free;

  FReportTmp.Free;

  FPDFExport.Free;
  FBMPExport.Free;
  FTIFFExport.Free;
  FJPEGExport.Free;
  FRTFExport.Free;
  FXLSExport.Free;
  FXMLExport.Free;

end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  //
  FReport3.Clear;
  FReport3.PrepareReport();
  FReport3.LoadFromFile('c:\11.fr3');
  FReport3.PrepareReport(False);

  FReport3.LoadFromFile('c:\11.fr3');
  FReport3.PrepareReport(False);


//  FReport3.Preview := FPreview;
//  FPreview.PreviewPages.Outline.AddItem('100s',100);
//  FPreview.OutlineVisible := False;
  FReport3.ShowPreparedReport;

end;

procedure TForm1.Button2Click(Sender: TObject);
begin

  FPreview.Next;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  FPreview.Print;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  FReport3.Export(FPDFExport);
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
  FPreview.Show;
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
  
  FReport3.Clear;
  FReport3.LoadFromFile('c:\11.fr3');
  FReport3.DesignReport;;
end;



procedure TForm1.Button7Click(Sender: TObject);
var
  PreviewPages : TfrxPreviewPages;
begin
  FReport3.Clear;
  FReport3.PrepareReport();
  FReport3.LoadFromFile('c:\11.fr3');
  FReport3.PrepareReport(False);

//  FReport3.LoadFromFile('c:\11.fr3');
//  FReport3.PrepareReport(False);
  
  FReport3.Preview := FPreview;
  FPreview.PreviewPages.Outline.AddItem('100s',100);
  FPreview.OutlineVisible := False;
  FReport3.ShowPreparedReport;

  FPDFExport.ShowDialog := False;
  FPDFExport.FileName := 'c:\test.pdf';
  FReport3.Export(FPDFExport);
//  PreviewPages := TfrxPreviewPages.Create(FReport3);
//  PreviewPages.Export(FPDFExport);
  //FReport3.Export();

end;

end.
